/**
 * API功能：关于参数配置类的API，包括菜单、日志、数据字典等
 */
import axios from 'axios'
let token = localStorage.getItem('authorization')
// console.log('token',token);
axios.defaults.headers.common['Authorization'] = token;
// /system-api nginx代理前缀
var baseUrl = '/sys'
/**
 * 字典管理接口
 */
// 获取数据字典数据
export const getDictList = params => axios.get(`${baseUrl}/dict/list`, { params: params });
// 新增数据字典
export const addDict = params => axios.post(`${baseUrl}/dict/add`, params)
// 获取数据字典下拉子项
export const getDictChildList = params => axios.get(`${baseUrl}/dict/child-list`, { params: params });
// 删除数据字典
export const deleteDict = params => axios.delete(`${baseUrl}/dict/delete`, { params: params });
// 通过id查找字典详情
export const getDictDetails = params => axios.get(`${baseUrl}/dict/details`, { params: params });
// 修改数据字典
export const updateDict = params => axios.put(`${baseUrl}/dict/update`, params);
/**
 * 菜单管理接口
 */
// 获取菜单管理列表
export const getMenuList = params => axios.get(`${baseUrl}/menu/list`, { params: params });
// 新增菜单
export const addMenu = params => axios.post(`${baseUrl}/menu/add`, params);
// 获取子菜单列表
export const getMenuChildList = params => axios.get(`${baseUrl}/menu/child-list`, { params: params });
// 删除菜单
export const deleteMenu = params => axios.delete(`${baseUrl}/menu/delete`, { params: params });
// 查看菜单详情
export const getMenuDetails = params => axios.get(`${baseUrl}/menu/details`, { params: params });
// 更新菜单
export const updateMenu = params => axios.put(`${baseUrl}/menu/update`, params);

// 获取当前用户的权限菜单
export const getPowerMenu = params => axios.get(`${baseUrl}/login-user/power/menu`, { params: params });

// 获取权限管理角色列表
export const getPowerRole = params => axios.get(`${baseUrl}/role/power/list`, { params: params });
// 获取权限管理事项下机构列表
export const getPowerEventOrg = params => axios.get(`${baseUrl}/login-user/power/item-organize`, { params: params });
// 获取权限管理事项下地区列表
export const getPowerEventArea = params => axios.get(`${baseUrl}/login-user/power/item-area`, { params: params });

/**
 * 权限管理
 */
// 获取权限管理列表
export const getPermissionList = params => axios.get(`${baseUrl}/permission/list`, { params: params });

/**
 * 日志管理
 */
// 查询日志列表
export const getLogList = params => axios.get(`${baseUrl}/oper/log/list`, { params: params });
// 导出日志列表
export const exportLogList = params => axios.get(`${baseUrl}/oper/log/export`, {
  params,
  responseType: 'blob'
});
